using System;
using System.Collections.Generic;
using System.Net;
using MX.Core.Caching.Redis.Configuration;

namespace MX.Core.Caching.Redis.Configuration
{
	/// <summary>
	/// Configuration class
	/// </summary>
	public class RedisClientConfiguration : IRedisClientConfiguration
	{

		/// <summary>
		/// Initializes a new instance of the <see cref="T:MemcachedClientConfiguration"/> class.
		/// </summary>
		public RedisClientConfiguration()
		{
			this.Servers = new List<IPEndPoint>();
			this.SocketPool = new SocketPoolConfiguration();
		}

		/// <summary>
		/// Adds a new server to the pool.
		/// </summary>
		/// <param name="address">The address and the port of the server in the format 'host:port'.</param>
		public void AddServer(string address)
		{
			this.Servers.Add(ConfigurationHelper.ResolveToEndPoint(address));
		}

		/// <summary>
		/// Adds a new server to the pool.
		/// </summary>
		/// <param name="address">The host name or IP address of the server.</param>
		/// <param name="port">The port number of the memcached instance.</param>
		public void AddServer(string host, int port)
		{
			this.Servers.Add(ConfigurationHelper.ResolveToEndPoint(host, port));
		}

		/// <summary>
		/// Gets a list of <see cref="T:IPEndPoint"/> each representing a Memcached server in the pool.
		/// </summary>
		public IList<IPEndPoint> Servers { get; private set; }

		/// <summary>
		/// Gets the configuration of the socket pool.
		/// </summary>
		public ISocketPoolConfiguration SocketPool { get; private set; }





		#region [ interface                     ]

		IList<System.Net.IPEndPoint> IRedisClientConfiguration.Servers
		{
			get { return this.Servers; }
		}

		ISocketPoolConfiguration IRedisClientConfiguration.SocketPool
		{
			get { return this.SocketPool; }
		}


		#endregion
	}
}

#region [ License information          ]
/* ************************************************************
 * 
 *    Copyright (c) 2010 Attila Kisk? enyim.com
 *    
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *    
 *        http://www.apache.org/licenses/LICENSE-2.0
 *    
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 *    
 * ************************************************************/
#endregion
